package com.zl.pro.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zl.pro.pojo.PersonalAssets;
import com.zl.pro.service.PersonalAssetsService;
import com.zl.pro.utils.Result;

@RestController

public class PersonalAssetsController {
	
	@Autowired
	PersonalAssetsService personalAssetsService;
	
	@RequestMapping(value="findPersonalAssets",method=RequestMethod.GET)
	public Result findPersonalAssets(@RequestParam(defaultValue="1",value = "pageNum")Integer pageNum,@RequestParam("userid") Long userid){
//         System.out.println(userid);
		//默认第一页开始、一行显示4个
        PageHelper.startPage(pageNum,4);
        //原有的查询方法（需写在startpage后）
        List<PersonalAssets> list=personalAssetsService.findPersonalAssets(userid);
       
        //pagehelper默认写法、传递session
        PageInfo<PersonalAssets> pageInfo = new PageInfo<PersonalAssets>(list);
//        System.out.println(list);
		Result result=new Result();
		result.setStatus(200);
		result.setMsg("查询个人资产成功");
		result.setData(pageInfo);
		return result;
	}

}
